﻿using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using Project2004.Jigsaw.Controls;
using Project2004.Jigsaw.Models;
using Project2004.Jigsaw.Presenters;
using Project2004.Jigsaw.Utils;
using System.Collections.Generic;

namespace Project2004.Jigsaw.Views;

public partial class MainView : UserControl
{
    private MainPresenter _presenter;

    public MainView()
    {
        InitializeComponent();
        _presenter =   new MainPresenter(this);
    }

    protected override void OnLoaded(RoutedEventArgs e)
    {
        base.OnLoaded(e);

        //var imageSource = new Bitmap(@"C:\Users\fan.lai\Pictures\OIP-C.jpg");

        //var scene = new Scene(imageSource.Size.Width, imageSource.Size.Height, 8, 5);
        //var size = scene.Size;
        //var boundSize = FullConfigJigsawShapeData.GetBoundSizeFromBorderLen(size);
        //var extend = FullConfigJigsawShapeData.GetExtend(size);

        //var jigsawBlocks = new List<JigsawBlock2>();
        //foreach (var item in scene.Blocks)
        //{
        //    var jigsawBlock = new JigsawBlock2(imageSource, scene, item);

        //    PART_Canvas.Children.Add(jigsawBlock);
        //    jigsawBlocks.Add(jigsawBlock);
        //}

        //foreach (var item in jigsawBlocks)
        //{
        //    Canvas.SetLeft(item, (size) * item.Block.X);
        //    Canvas.SetTop(item, (size) * item.Block.Y);
        //}

    }


}
